package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhAffDAO;
import com.cssy.yd.logic.entity.LogicWhAffDO;
import com.cssy.yd.logic.entity.LogicWhAffStockFinanceDO;
import com.cssy.yd.logic.vo.LogicWhAffVO;
import com.cssy.yd.logic.vo.LogicWhAffVO1;
import com.plat.helper.SearchConditions;

import java.util.List;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2012-12-26
 */
public class LogicWhAffDAOImpl extends SqlMapClientDaoSupport implements LogicWhAffDAO {

    /**
     * 插入数据
     * @param logicWhAffDO
     * @return 插入数据的主键
     */
    public String insertLogicWhAffDO(LogicWhAffDO logicWhAffDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicWhAff.insert", logicWhAffDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhAffDO
     * @return 查出的记录数
     */
    public Integer countLogicWhAffDOByExample(LogicWhAffDO logicWhAffDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAff.countByDOExample", logicWhAffDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhAffDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhAffDO(LogicWhAffDO logicWhAffDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWhAff.update", logicWhAffDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhAffDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhAffDO> findListByExample(LogicWhAffDO logicWhAffDO) throws DataAccessException {
        List<LogicWhAffDO> list = getSqlMapClientTemplate().queryForList("LogicWhAff.findListByDO", logicWhAffDO);
        return list;
    }

    /**
     * 根据主键获取logicWhAffDO
     * @param id
     * @return logicWhAffDO
     */
    public LogicWhAffDO findLogicWhAffDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhAffDO logicWhAffDO = (LogicWhAffDO) getSqlMapClientTemplate().queryForObject("LogicWhAff.findByPrimaryKey", id);
        return logicWhAffDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhAffDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhAff.deleteByPrimaryKey", id);
        return rows;
    }
    
    @Override
	public List<LogicWhAffDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicWhAffDO> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.find", scs);
		return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAff_ex.count", scs);
		return count;
	}
	
	/**
	 * 查询详细出入库明细
	 * @return
	 * @throws DataAccessException
	 */
	@Override
	public List<LogicWhAffVO> findListBySearchConForDetails(SearchConditions scs)
			throws DataAccessException {
		List<LogicWhAffVO> list = getSqlMapClientTemplate().queryForList("LogicWhAff.findListBySearchConForDetails", scs);
		return list;
	}
	/**
	 * 查询出入库明细条数用于分页
	 */
	@Override
	public Integer findListBySearchConForDetailsCount(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAff.findListBySearchConForDetailsCount", scs);
		return count;
	}

	@Override
	public List<LogicWhAffVO> findAll(Map map)
			throws DataAccessException {
		List<LogicWhAffVO> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.findAll", map);
		return list;
	}

	@Override
	public Integer countAll(Map map) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAff_ex.countAll", map);
		return count;
	}
	
	@Override
	public List<LogicWhAffVO1> findAll1(Map map)
			throws DataAccessException {
		List<LogicWhAffVO1> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.findAll1", map);
		return list;
	}

	@Override
	public Integer countAll1(Map map) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAff_ex.countAll1", map);
		return count;
	}

	@Override
	public List<LogicWhAffStockFinanceDO> findFinance(Map map)
			throws DataAccessException {
		List<LogicWhAffStockFinanceDO> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.findFinance", map);
		return list;
	}

	@Override
	public Integer countFinance(Map map) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhAff_ex.countFinance", map);
		return count;
	}

	@Override
	public LogicWhAffStockFinanceDO findInOutBycode(Map map)
			throws DataAccessException {
		LogicWhAffStockFinanceDO lwsf = (LogicWhAffStockFinanceDO) getSqlMapClientTemplate().queryForObject("LogicWhAff_ex.findInOutBycode", map);
		return lwsf;
	}

	@Override
	public LogicWhAffStockFinanceDO findCKBycode(Map map)
			throws DataAccessException {
		LogicWhAffStockFinanceDO lwsf = (LogicWhAffStockFinanceDO) getSqlMapClientTemplate().queryForObject("LogicWhAff_ex.findCKBycode", map);
		return lwsf;
	}
	@Override
	public List<LogicWhAffVO> findStarQty(Map map)
			throws DataAccessException {
		List<LogicWhAffVO> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.findstarqty", map);
		return list;
	}
	@Override
	public List<LogicWhAffVO> findEndQty(Map map)
			throws DataAccessException {
		List<LogicWhAffVO> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.findendqty", map);
		return list;
	}
	@Override
	public List<LogicWhAffVO> findInOutQty(Map map)
			throws DataAccessException {
		List<LogicWhAffVO> list = getSqlMapClientTemplate().queryForList("LogicWhAff_ex.findinoutqty", map);
		return list;
	}
	
}